#ifndef __My_TASK_H__
#define __My_TASK_H__

#include "TcpConnection.h" 
#include "LRUmanager.h"
#include "../Web_Search/WebPage.h"
#include <map>

using TcpConnectionPtr = shared_ptr<TcpConnection>;
using std::map;

#include "myLog.h"
using namespace du;

// 接收到的任务
class MyTask{
public:
    MyTask(const TcpConnectionPtr &con, const pair<int, string> msgParse);

    // 将处理好的 msg 发送给 TcpConnection, 通过 TcpConnection 返回给客户端
    void process(void* mode, LRUmanager &m);
    void handleMsgKey(void* mode, LRUmanager &m);
    void handleMsgWeb(void* mode);
    
    // Redis 缓存相关
    void setRedis(string word, vector<WebPage> &queryResult);
    vector<WebPage> getRedis(string word, int number);

private:
    WebPage _wp;
    pair<int, void*> queryResult;
    pair<int, string> _msg;
    TcpConnectionPtr _con;
    map<string, int> _pages;
};

#endif // !__My_TASK_H__
